package graphic.primitives.car;

import graphic.primitives.general.Circle;
import graphic.primitives.general.GraphicObject;
import graphic.primitives.general.IGraphicObject;

/**
 * 
 * @author vit.terl
 *
 */
public class Wheel extends GraphicObject implements IGraphicObject{
	private int sirka;
	private double uhel = 45;

	/**
	 * 
	 * @param x
	 * @param y
	 * @param sirka
	 */
	public Wheel(int x, int y, int sirka) {
		super(x, y);
		this.sirka = sirka;
	}
	
	@Override
	public void redraw() {
		Circle c = new Circle(x, y, sirka/2);
		c.redraw();
		double strana  = Math.sin(Math.toRadians(uhel));
		double strana2 = Math.cos(Math.toRadians(uhel));
		double strana3 = Math.sin(Math.toRadians(uhel+45));
		double strana4 = Math.cos(Math.toRadians(uhel+45));

		mainWindow.line(x - (int)(sirka/2 * strana4), y - (int)(sirka/2 * strana3), x + (int)(sirka/2 * strana4), y + (int)(sirka/2 * strana3));
		mainWindow.line(x - (int)(sirka/2 * strana2), y - (int)(sirka/2 * strana), x + (int)(sirka/2 * strana2), y + (int)(sirka/2 * strana));		
		mainWindow.line(x - (int)(sirka/2 * strana), y + (int)(sirka/2 * strana2), x + (int)(sirka/2 * strana), y - (int)(sirka/2 * strana2));
		mainWindow.line(x -(int)(sirka/2 * -strana3), y - (int)(sirka/2 * strana4), x + (int)(sirka/2 * -strana3), y + (int)(sirka/2 * strana4));
	}
	
	public void setRotationAngle(int uhel) {
		this.uhel += uhel;
	}
}
